(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[43],{112:function(e,o,t){"use strict";var n=t(0),c=t(57),a=t(4),s=t.n(a),r=t(79);t(133),o.a=({className:e,showSpinner:o=!1,children:t,variant:a="contained",...l})=>{const i=s()("wc-block-components-button","wp-element-button",e,a,{"wc-block-components-button--loading":o});return Object(n.createElement)(c.a,{className:i,...l},o&&Object(n.createElement)(r.a,null),Object(n.createElement)("span",{className:"wc-block-components-button__text"},t))}},114:function(e,o){},133:function(e,o){},146:function(e,o,t){"use strict";var n=t(0),c=t(1),a=t(4),s=t.n(a),r=(t(223),t(79));o.a=({children:e,className:o,screenReaderLabel:t,showSpinner:a=!1,isLoading:l=!0})=>Object(n.createElement)("div",{className:s()(o,{"wc-block-components-loading-mask":l})},l&&a&&Object(n.createElement)(r.a,null),Object(n.createElement)("div",{className:s()({"wc-block-components-loading-mask__children":l}),"aria-hidden":l},e),l&&Object(n.createElement)("span",{className:"screen-reader-text"},t||Object(c.__)("Loading…","woocommerce")))},223:function(e,o){},313:function(e,o,t){"use strict";t.d(o,"a",(function(){return i}));var n=t(1),c=t(5),a=t(3),s=t(23),r=t(12),l=t(72);const i=(e="")=>{const{cartCoupons:o,cartIsLoading:t}=Object(l.a)(),{createErrorNotice:i}=Object(c.useDispatch)("core/notices"),{createNotice:p}=Object(c.useDispatch)("core/notices"),{setValidationErrors:u}=Object(c.useDispatch)(a.VALIDATION_STORE_KEY),{isApplyingCoupon:b,isRemovingCoupon:m}=Object(c.useSelect)((e=>{const o=e(a.CART_STORE_KEY);return{isApplyingCoupon:o.isApplyingCoupon(),isRemovingCoupon:o.isRemovingCoupon()}}),[i,p]),{applyCoupon:d,removeCoupon:O}=Object(c.useDispatch)(a.CART_STORE_KEY);return{appliedCoupons:o,isLoading:t,applyCoupon:o=>d(o).then((()=>(Object(r.applyCheckoutFilter)({filterName:"showApplyCouponNotice",defaultValue:!0,arg:{couponCode:o,context:e}})&&p("info",Object(n.sprintf)(/* translators: %s coupon code. */
Object(n.__)('Coupon code "%s" has been applied to your cart.',"woocommerce"),o),{id:"coupon-form",type:"snackbar",context:e}),Promise.resolve(!0)))).catch((e=>(u({coupon:{message:Object(s.decodeEntities)(e.message),hidden:!1}}),Promise.resolve(!1)))),removeCoupon:o=>O(o).then((()=>(Object(r.applyCheckoutFilter)({filterName:"showRemoveCouponNotice",defaultValue:!0,arg:{couponCode:o,context:e}})&&p("info",Object(n.sprintf)(/* translators: %s coupon code. */
Object(n.__)('Coupon code "%s" has been removed from your cart.',"woocommerce"),o),{id:"coupon-form",type:"snackbar",context:e}),Promise.resolve(!0)))).catch((o=>(i(o.message,{id:"coupon-form",context:e}),Promise.resolve(!1)))),isApplyingCoupon:b,isRemovingCoupon:m}}},384:function(e,o){},451:function(e,o,t){"use strict";var n=t(0),c=t(1),a=t(112),s=t(146),r=t(11),l=t(12),i=t(5),p=t(3),u=t(4),b=t.n(u);t(384),o.a=Object(r.withInstanceId)((({instanceId:e,isLoading:o=!1,onSubmit:t,displayCouponForm:r=!1})=>{const[u,m]=Object(n.useState)(""),[d,O]=Object(n.useState)(!r),g=`wc-block-components-totals-coupon__input-${e}`,j=b()("wc-block-components-totals-coupon__content",{"screen-reader-text":d}),{validationErrorId:_}=Object(i.useSelect)((e=>({validationErrorId:e(p.VALIDATION_STORE_KEY).getValidationErrorId(g)})));return Object(n.createElement)("div",{className:"wc-block-components-totals-coupon"},d?Object(n.createElement)("a",{role:"button",href:"#wc-block-components-totals-coupon__form",className:"wc-block-components-totals-coupon-link","aria-label":Object(c.__)("Add a coupon","woocommerce"),onClick:e=>{e.preventDefault(),O(!1)}},Object(c.__)("Add a coupon","woocommerce")):Object(n.createElement)(s.a,{screenReaderLabel:Object(c.__)("Applying coupon…","woocommerce"),isLoading:o,showSpinner:!1},Object(n.createElement)("div",{className:j},Object(n.createElement)("form",{className:"wc-block-components-totals-coupon__form",id:"wc-block-components-totals-coupon__form"},Object(n.createElement)(l.ValidatedTextInput,{id:g,errorId:"coupon",className:"wc-block-components-totals-coupon__input",label:Object(c.__)("Enter code","woocommerce"),value:u,ariaDescribedBy:_,onChange:e=>{m(e)},focusOnMount:!0,validateOnMount:!1,showError:!1}),Object(n.createElement)(a.a,{className:"wc-block-components-totals-coupon__button",disabled:o||!u,showSpinner:o,onClick:e=>{e.preventDefault(),void 0!==t?t(u).then((e=>{e&&(m(""),O(!0))})):(m(""),O(!0))},type:"submit"},Object(c.__)("Apply","woocommerce"))),Object(n.createElement)(l.ValidationInputError,{propertyName:"coupon",elementId:g}))))}))},533:function(e,o,t){"use strict";t.r(o);var n=t(0),c=t(451),a=t(313),s=t(2),r=t(12);o.default=({className:e=""})=>{const o=Object(s.getSetting)("couponsEnabled",!0),{applyCoupon:t,isApplyingCoupon:l}=Object(a.a)("wc/checkout");return o?Object(n.createElement)(r.TotalsWrapper,{className:e},Object(n.createElement)(c.a,{onSubmit:t,isLoading:l})):null}},79:function(e,o,t){"use strict";var n=t(0);t(114),o.a=()=>Object(n.createElement)("span",{className:"wc-block-components-spinner","aria-hidden":"true"})}}]);